/*
*封装storage方法
*/

/*
*存
*/
export const setItem = (key, value) => {
  if (typeof value === 'object') {
    value = JSON.stringify(value)
  }
  window.localStorage.setItem(key, value)
}

/*
*取
*/
export const getItem = key => {
  var str = window.localStorage.getItem(key)
  try {
    return JSON.parse(str)
  } catch (error) {
    return str
  }
}
/*
*删
*/
export const removeItem = key => {
  window.localStorage.removeItem(key)
}
